package util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class OrderNo {

	public static synchronized String getOdn() throws Exception {
		Thread.sleep(1);
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmmss-");
		String s = String.valueOf(System.currentTimeMillis());
		String str = sdf.format(new Date());
		str += s.substring(s.length() - 3, s.length());
		return "B" + str;
	}

	public static String orderNo2String(String orderNo) {
		String date = "20";
		date += orderNo.substring(1, 3) + "-" + orderNo.substring(3, 5) + "-"
				+ orderNo.substring(5, 7) + " " + orderNo.substring(8, 10)
				+ ":" + orderNo.substring(10, 12) + ":"
				+ orderNo.substring(12, 14);
		return date;
	}

	public static void main(String args[]) throws Exception {
		for (int i = 0; i < 1000; i++) {
			System.out.println(getOdn());
		}
		System.out.println(orderNo2String(getOdn()));
	}
}
